home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-11-30 | 3.4 KB | 153 lines | [TEXT/KAHL] |
- /***********************************************************************************
- CExpanderHeader.cp
-
- Copyright © 1994 B-Ray Software. All rights reserved.
- Developed using Symantec C++ 7.0.2 and Symantec's TCL library.
- Portions of this code courtesy Symantec, Inc.
-
- This code may be freely distributed as long as this notice remains. This code
- may not be used in any commercial software without the consent of B-Ray Software.
-
- ---
-
- CExpanderHeader class provides a label and a button for a CExpander object.
-
- ***********************************************************************************/
- #include <Commands.h>
-
- #include "CExpanderButton.h"
- #include "CExpanderLabel.h"
- #include "ExpanderMessages.h"
-
- #include "CExpanderHeader.h"
-
-
- short const CExpanderHeader::kExpanderButtonSize = 16;
-
-
- TCL_DEFINE_CLASS_D1( CExpanderHeader, CExpanderPane );
-
-
- /*
- * CExpanderHeader constructor
- *
- * Default constructor - should only be used when created by a file read.
- */
-
- CExpanderHeader :: CExpanderHeader() : CExpanderPane()
- {
- itsLabel = NULL;
- itsButton = NULL;
-
- TCL_END_CONSTRUCTOR
- }
-
-
- /*
- * CExpanderHeader constructor
- *
- * Normal constructor - should always be used when a new object is created
- * in code.
- */
-
- CExpanderHeader :: CExpanderHeader( CView *anEnclosure, CBureaucrat *aSupervisor,
- short aWidth, short aHeight, short aHLoc, short aVLoc,
- SizingOption aHSizing, SizingOption aVSizing )
- : CExpanderPane( anEnclosure, aSupervisor, aWidth, aHeight, aHLoc, aVLoc,
- aHSizing, aVSizing )
- {
- itsLabel = NULL;
- itsButton = NULL;
-
- SetWantsClicks( TRUE ); // want clicks for our button
-
- try_ {
- MakeComponents(); // create button and label panes
- }
- catch_all_() {
- throw_same_();
- }
- end_try_;
- }
-
-
- /*
- * CExpanderHeader destructor
- *
- * Just a place-holder for Inspector
- */
-
- CExpanderHeader :: ~CExpanderHeader()
- {
- TCL_START_DESTRUCTOR
- }
-
-
- /*
- * IExpanderHeader method
- *
- * Private method that creates our button and label panes.
- */
-
- void CExpanderHeader :: MakeComponents( void )
- {
- MakeExpanderButton();
- AppendChild( MakeExpanderLabel() );
- }
-
-
- void CExpanderHeader :: MakeExpanderButton( void )
- {
- short aWidth = kExpanderButtonSize;
- short aHeight = kExpanderButtonSize;
-
- /*
- * Create button. NOTE: we don't treat the button as a child. Otherwise, our label
- * would be positioned BELOW the button (CColumnizer behavior). We just treat this
- * as a normal pane, and offset the label so they won't overlap.
- */
- itsButton = TCL_NEW( CExpanderButton, ( this, itsSupervisor, aWidth, aHeight ) );
- }
-
-
- CExpanderLabel *CExpanderHeader :: MakeExpanderLabel( void )
- {
- short aWidth = width - ( kExpanderButtonSize + 4 );
- short aHeight = kExpanderButtonSize + 4;
- short aHLoc = kExpanderButtonSize + 4;
- short hVLoc = 0;
-
- itsLabel = TCL_NEW( CExpanderLabel, ( this, itsSupervisor, aWidth, aHeight, aHLoc, aVLoc,
- sizFIXEDSTICKY, sizFIXEDSTICKY );
- }
-
-
- /*
- * PutTo method - OVERRIDE
- *
- * Writes to the stream all the info we need to save.
- */
-
- void CExpanderHeader :: PutTo( CStream &stream )
- {
- CExpanderPane::PutTo( stream );
-
- stream << itsLabel;
- stream << itsButton;
- }
-
-
- /*
- * GetFrom method - OVERRIDE
- *
- * Reads from the stream all of the info that we saved.
- */
-
- void CExpanderHeader :: GetFrom( CStream &stream )
- {
- CExpanderPane::GetFrom( stream );
-
- itsLabel = (CExpanderLabel *)stream.GetView( this, itsSupervisor );
- itsButton = (CExpanderButton *)stream.GetView( this, itsSupervisor );
- }
-